package com.smart.service.web.impl;

import java.util.List;
import java.util.ArrayList;
import com.smart.entity.SsAttendance;
import com.smart.util.ExportExcelUtils;
import javax.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Service;
import com.smart.service.impl.BaseServiceImpl;
import com.smart.vo.dto.WebSsAttendanceExcelDTO;
import com.smart.service.web.WebAttendanceService;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author lgb
 * @date 2020年6月15日 上午10:55:38
 * Copyright (C) 深圳工勘科技
 * @说明: 作业记录web端impl
 **/
@Service("webAttendanceService")
public class WebAttendanceServiceImpl extends BaseServiceImpl<SsAttendance,Long>
        implements WebAttendanceService{

	@Override
	@Transactional(readOnly=true)
	public void exportExcel(HttpServletResponse response) {
		List<WebSsAttendanceExcelDTO> dtoList=new ArrayList<>();
        List<SsAttendance> attendanceList=super.findAll();
        if(!attendanceList.isEmpty()){
        	for(SsAttendance s : attendanceList){
        		WebSsAttendanceExcelDTO dto=new WebSsAttendanceExcelDTO();
            	dto.setCreateDate(s.getCreateDate());
            	dto.setCreateTime(s.getCreateTime());
            	dto.setIdentity(s.getIdentity());
            	dto.setLocation(s.getLocation());
            	dto.setNickName(s.getNickName());
            	dto.setPhone(s.getPhone());
        	}
        }
        String title = "考勤记录.xlsx";
        String[] rowName = {"日期","姓名","手机号","身份","打卡时间","打卡地点"};
        List<Object> datalist = new ArrayList<>(1);
        datalist.addAll(dtoList);
        ExportExcelUtils.exportExcel(response, title, rowName, datalist);
	}

}
